/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package orderProcessingProcess.callbackHandlerSecurity;

import java.io.IOException;
import javax.security.auth.callback.Callback;
import javax.security.auth.callback.CallbackHandler;
import javax.security.auth.callback.UnsupportedCallbackException;
import org.apache.ws.security.WSPasswordCallback;

/**
 *
 * @author dreni
 */
public class ClientPasswordCallbackHandler implements CallbackHandler {

    public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {

        WSPasswordCallback pc = (WSPasswordCallback) callbacks[0];

        // set the password
       if (pc.getIdentifier().equals("username")) {
            pc.setPassword("password");
        } else {
            pc.setPassword("invalidUser");
        }
    }
}
